<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>百度地图04</title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />  
<link href="" rel="stylesheet">

<style type="text/css">  
    html{height:100%}  
    body{height:100%;margin:0px;padding:0px}  
    #container{height:100%}  
</style>  

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=7DDU0BmgurkEgCqiGyvAf55qAMKzMfv8"></script>

</head>
<body>
    <div id="container"></div> 

	<script type="text/javascript">
		alert("根据坐标数组自动获取地图中心点和缩放【百度API实现】");
		//数据准备
		var points = [
			{"lng":116,"lat":40,"status":1,"id":50},
			{"lng":117,"lat":31,"status":1,"id":2},
			{"lng":116,"lat":34,"status":0,"id":3},
			{"lng":118,"lat":39,"status":0,"id":4},
			{"lng":110,"lat":35,"status":1,"id":5},

			{"lng":106.552113,"lat":29.555927,"status":1,"id":5},
			{"lng":105.726678,"lat":29.71462},

			{"lng":100.012332,"lat":39.574658},
			{"lng":40.82609,"lat":38.887844},
			{"lng":160.482109,"lat":65.462587},
			{"lng":104.296764,"lat":34.869358},
			{"lng":91.786602,"lat":31.276714},

		];

		// var points = [];  // 没有坐标的情况【显示整个世界】
		
		var map = new BMap.Map("container");//初始化地图

		addMarker(points);//把原始数据的轨迹点添加到地图上。

		map.enableScrollWheelZoom();//滚轮放大缩小




		// 官方API
		// var points = [point1, point2,point3];  
		var view = map.getViewport(eval(points));  
		var mapZoom = view.zoom;   
		var centerPoint = view.center;   
		map.centerAndZoom(centerPoint,mapZoom);  

		//在轨迹点上创建图标，并添加点击事件
		function addMarker(points){ 
			var point,marker;
			// 创建标注对象并添加到地图   
			for(var i = 0,pointsLen = points.length;i <pointsLen;i++){
				point = new BMap.Point(points[i].lng,points[i].lat);	
				marker = new BMap.Marker(point);   
				map.addOverlay(marker);
			}
		}     

	</script>

</body>
</html>